package mn.slide.labmed.info;

import mn.slide.labmed.MyDialog;
import mn.slide.labmed.R;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.Button;
import android.widget.EditText;

public class UberActivity extends Activity
{

	@Override
	public void onCreate( Bundle savedInstanceState )
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.uber);

		// Uberlong1 Text1
		WebView mWebView = (WebView) findViewById(R.id.uberlongWV);
		mWebView.setVerticalScrollBarEnabled(false);
		mWebView.setScrollContainer(false);
		String text = "<html><head> <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"></head><body>" + "<p align=\"justify\"><font>" + getString(R.string.uberlong) + "</font></p> " + "</body></html>";
		WebSettings webSettings = mWebView.getSettings();
		webSettings.setDefaultFontSize(14);
		mWebView.setBackgroundColor(0);
		mWebView.setBackgroundResource(R.drawable.background);
		mWebView.loadData(text, "text/html", "utf-8");
		// Uberlong2 Text 2

		WebView mWebView2 = (WebView) findViewById(R.id.uberlongWV2);
		mWebView2.setVerticalScrollBarEnabled(false);
		mWebView2.setScrollContainer(false);
		String text2 = "<html><head> <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"></head><body>" + "<p align=\"justify\"><b>" + getString(R.string.uberlong2) + "</b></p> " + "</body></html>";
		WebSettings webSettings2 = mWebView2.getSettings();
		webSettings2.setDefaultFontSize(14);
		mWebView2.setBackgroundColor(0);
		mWebView2.setBackgroundResource(R.drawable.background);
		mWebView2.loadData(text2, "text/html", "utf-8");
		Button zuruck = (Button) findViewById(R.id.zuruckuber);

		zuruck.setOnClickListener(new View.OnClickListener()
		{
			public void onClick( View v )
			{
				InfoTabGroupActivity.group.back();
			}
		});

		EditText searchbox = (EditText) findViewById(R.id.uber_search);
		searchbox.setOnKeyListener(new View.OnKeyListener()
		{

			public boolean onKey( View v , int keyCode , KeyEvent event )
			{
				if (keyCode == KeyEvent.KEYCODE_ENTER)
				{
					EditText searchbox = (EditText) v;
					InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
					imm.hideSoftInputFromWindow(searchbox.getWindowToken(), 0);
					InfoTabGroupActivity.group.goSearchActivity(searchbox.getText().toString());
				}
				return false;
			}
		});
		findViewById(R.id.uber1).setOnClickListener(new View.OnClickListener()
		{

			public void onClick( View v )
			{
				sendmail("eberhard@labmed.de");
			}
		});
		findViewById(R.id.uber2).setOnClickListener(new View.OnClickListener()
		{

			public void onClick( View v )
			{
				sendmail("sirowej@labmed.de");
			}
		});
		findViewById(R.id.uber3).setOnClickListener(new View.OnClickListener()
		{

			public void onClick( View v )
			{
				sendmail("pranada@labmed.de");
			}
		});
		findViewById(R.id.uber4).setOnClickListener(new View.OnClickListener()
		{

			public void onClick( View v )
			{
				sendmail("drache@labmed.de");
			}
		});
		findViewById(R.id.uber5).setOnClickListener(new View.OnClickListener()
		{

			public void onClick( View v )
			{
				sendmail("kappelhoff@labmed.de");
			}
		});
		findViewById(R.id.uber6).setOnClickListener(new View.OnClickListener()
		{

			public void onClick( View v )
			{
				sendmail("adamek@labmed.de");
			}
		});
		findViewById(R.id.uber7).setOnClickListener(new View.OnClickListener()
		{

			public void onClick( View v )
			{
				sendmail("finckh@labmed.de");
			}
		});
		findViewById(R.id.uber8).setOnClickListener(new View.OnClickListener()
		{

			public void onClick( View v )
			{
				sendmail("schwan@labmed.de");
			}
		});
		findViewById(R.id.uber9).setOnClickListener(new View.OnClickListener()
		{

			public void onClick( View v )
			{
				sendmail("demtroeder@labmed.de");
			}
		});
		Button foot = (Button) findViewById(R.id.uberfoot);
		foot.setOnClickListener(new View.OnClickListener()
		{

			public void onClick( View v )
			{
				Intent intent = new Intent(UberActivity.this, MyDialog.class);
				Bundle bundle = new Bundle();
				bundle.putString("title", "www.labmed.de");
				intent.putExtras(bundle);
				startActivity(intent);
			}
		});

	}

	public void sendmail( String mail )
	{
		Intent intent = new Intent(android.content.Intent.ACTION_SEND);
		intent.setType("text/plain");
		intent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { mail });
		intent.putExtra(Intent.EXTRA_SUBJECT, "subject of email");
		intent.putExtra(Intent.EXTRA_TEXT, "body of email");
		startActivity(Intent.createChooser(intent, "Send mail"));
	}
}
